import { getAdminHouseholdDetailsApi } from '@/apis/household'
import { Col, Modal, Row } from 'antd'
import React, { useEffect, useState } from 'react'
import style from './index.module.scss'

// const titleList = [
//   {
//     title: '姓名',
//     dataIndex: 'householdName',
//   },
//   {
//     title: '性别',
//     dataIndex: 'gender',
//   },
//   {
//     title: '联系方式',
//     dataIndex: 'phone',
//   },
//   {
//     title: '地址',
//     dataIndex: 'householdAddr',
//   }
// ]

export default function ResidentDetailsModal({ isOpen, setIsOpen, id, successChange, titleList, title, method }) {
  const [list, setList] = useState({})
  const [loading, setLoading] = useState(false)
  useEffect(() => {
    setLoading(true)
    ; (async () => {
      const res = await method(id)
      const resObj = await res.json()
      console.log(resObj)
      setList(resObj.data || {})
      setLoading(false)
    })()
  }, [id, successChange])

  return (
    <Modal okText='确认' cancelText='取消' title={title} open={isOpen} onOk={() => setIsOpen()} onCancel={() => setIsOpen()} loading={loading}>
      {titleList.map((item, index) => (
        <Row key={index} className={style['row-style']}>
          <Col span={8} className={style['title-style']}>{item.title}</Col>
          <Col span={16} className={style['data-style']}>{list[item.dataIndex]}</Col>
        </Row>
      ))}
    </Modal>
  )
}
